<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>商品列表</title>
    <link rel="stylesheet" href="{{ asset('admin/libs/layui/css/layui.css') }}"/>
    <link rel="stylesheet" href="{{ asset('admin/module/admin.css?v=316 ')}}"/>
    <script type="text/javascript" src="{{ asset('admin/libs/sku/jquery.min.js') }}"></script>
    <script type="text/javascript" src="{{ asset('admin/libs/sku/createSkuTable.js?v16') }}"></script>
    <script type="text/javascript" src="{{ asset('admin/libs/sku/getSetSkuVals.js?1') }}"></script>

    <script type="text/javascript" src="{{ asset('/admin/libs/layui/layui.js')}} "></script>
    <script type="text/javascript" src="{{ asset('/admin/js/common.js')}} "></script>

    <script type="text/javascript" src="{{ asset('/admin/libs/selectpage/selectpage.js') }}"></script>


    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style>
        /** 评论列表弹窗样式 */
        .layui-layer-content > .layui-table-view {
            margin: 0;
        }

        /** 查看详情弹窗样式 */
        .paper-info-group {
            padding: 15px 25px;
        }

        .paper-info-group h3 {
            font-weight: bold;
            color: #000000;
            padding-bottom: 8px;
        }

        .paper-info-group p {
            color: #666;
            padding-bottom: 12px;
            font-size: 16px;
        }

        .paper-info-group .paper-info-group-imgs {
            padding-top: 5px;
        }

        .paper-info-group .paper-info-group-imgs img {
            margin-right: 15px;
            margin-bottom: 15px;
            cursor: zoom-in;
        }

        .paper-info-group .paper-info-group-imgs img:last-child {
            margin-right: 0;
        }

        /** 状态列 */
        *[lay-event] {
            cursor: pointer;
        }

        /* 日期组件不显示秒 */
        .laydate-time-list li:last-child {
            display: none;
        }

        .laydate-time-list li {
            width: 50% !important;
        }

        .laydate-time-list ol li {
            padding-left: 55px !important;
            width: 100% !important;
        }

    </style>
</head>
<body>

<!-- 加载动画 -->
<div class="page-loading">
    <div class="ball-loader">
        <span></span><span></span><span></span><span></span>
    </div>
</div>

<!-- 正文开始 -->
<div class="layui-fluid">

    <div class="layui-card">
        {{--<button id="demoEDBtnAddStudent" class="layui-btn">添加商品</button>--}}
        {{--<div class="layui-card-body">--}}
            {{--<table id="demoTableED1" lay-filter="demoTableED1"></table>--}}
        {{--</div>--}}

        <div class="layui-card-body">
            <!-- 表格顶部工具栏 -->
            <div class="layui-form toolbar">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label w-auto"></label>
                        <div class="layui-input-inline mr0">
                            <input name="experimentTypeName" class="layui-input" type="text" placeholder="输入商品名称"/>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button class="layui-btn icon-btn" lay-filter="searchSubmit" lay-submit>
                            <i class="layui-icon">&#xe615;</i>搜索
                        </button>
                        <button id="demoEDBtnAddStudent" class="layui-btn"><i class="layui-icon">&#xe654;</i>添加</button>
                    </div>
                </div>
            </div>
            <table id="demoTableED1" lay-filter="demoTableED1"></table>
        </div>
    </div>
</div>

<!-- 添加商品表单弹窗 -->
<script type="text/html" id="EDModelAddStudent">
    <form id="EDStudentForm" lay-filter="EDStudentForm" class="layui-form model-form layui-row">
        <input name="studentId" type="hidden"/>


        <div class="layui-col-md12" >
            <div class="layui-form-item">
                <label class="layui-form-label" style="padding-left: 0;padding-right: 0;width: 98px;">规格</label>
                <div class="layui-input-block">
                    <input  name="specia" id="specia" value="" class="layui-hide" lay-verType="tips"
                           lay-verify="required" required/>
                </div>
            </div>


            <ul class="SKU_TYPE">
                <li style="width: 110px;text-align: right" is_required='1' propid='3' sku-type-name="颜色">颜色：</li>
            </ul>
            <ul>
                <li><label><input type="checkbox" class="sku_value" propvalid='31'  value="土豪金"/>土豪金</label></li>
                <li><label><input type="checkbox" class="sku_value" propvalid='32' value="银白色"/>银白色</label></li>
                <li><label><input type="checkbox" class="sku_value" propvalid='33' value="深空灰"/>深空灰</label></li>
                <li><label><input type="checkbox" class="sku_value" propvalid='34' value="黑色"/>黑色</label></li>
                <li><label><input type="checkbox" class="sku_value" propvalid='33' value="玫瑰金"/>玫瑰金</label></li>
            </ul>
            <div class="clear"></div>

            <ul class="SKU_TYPE">
                <li style="width: 110px;text-align: right" is_required='1' propid='1' sku-type-name="存储"><em>*</em>型号：</li>
            </ul>
            <ul>
                <li><label><input type="checkbox" class="sku_value"  propvalid='11'  value="16G"/>16G</label></li>
                <li><label><input type="checkbox" class="sku_value"  propvalid='12' value="32G"/>32G</label></li>
                <li><label><input type="checkbox" class="sku_value" propvalid='13'  value="64G"/>64G</label></li>
                <li><label><input type="checkbox" class="sku_value" propvalid='14' value="128G"/>128G</label></li>
                <li><label><input type="checkbox" class="sku_value" propvalid='15' value="256G"/>256G</label></li>
            </ul>
            <div class="clear"></div>

            <ul class="SKU_TYPE">
                <li style="width: 110px;text-align: right" is_required='1' propid='2' sku-type-name="版本"><em>*</em>版本：</li>
            </ul>
            <ul>
                <li><label><input type="checkbox" class="sku_value" propvalid='21'  value="中国大陆版"/>中国大陆版</label></li>
                <li><label><input type="checkbox" class="sku_value" propvalid='22'  value="港版"/>港版</label></li>
                <li><label><input type="checkbox" class="sku_value" propvalid='23' value="韩版"/>韩版</label></li>
                <li><label><input type="checkbox" class="sku_value" propvalid='24' value="美版"/>美版</label></li>
                <li><label><input type="checkbox" class="sku_value" propvalid='25' value="日版"/>日版</label></li>
            </ul>
            <div class="clear"></div>

            <!--sku模板,用于克隆,生成自定义sku-->
            <div id="skuCloneModel" style="display: none;">
                <div class="clear"></div>
                <ul class="SKU_TYPE">
                    <li is_required='0' propid='' sku-type-name="">
                        <a href="javascript:void(0);" class="delCusSkuType">移除</a>
                        <input type="text" class="cusSkuTypeInput"/>：
                    </li>
                </ul>
                <ul>
                    <li>
                        <input type="checkbox" class="model_sku_val" propvalid='' value=""/>
                        <input type="text" class="cusSkuValInput"/>
                    </li>
                </ul>
                <div class="clear"></div>
            </div>
            <div class="clear"></div>
            <div id="skuTable">
                <table class="skuTable">
                    <tbody>
                    </tbody>
                </table>
            </div>


        </div>
        <div class="layui-col-md6">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label ">地区</label>
                    <div class="layui-input-inline" style="width: 558px;">
                        <input type="text" id="selectPage" name="citys" class=" " value="1,2" placeholder="选择或输入地区" >
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">商品名称</label>
                <div class="layui-input-block">
                    <input name="className" placeholder="请输入商品名称" type="text" class="layui-input"
                           lay-verType="tips" lay-verify="required" required/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">产品分类</label>
                <div class="layui-input-block">
                    <input name="profession" placeholder="请选择产品分类" lay-verType="tips" lay-verify="required" required/>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">入学年份</label>
                <div class="layui-input-block">
                    <input name="schoolYear" placeholder="请选择入学年份" type="text" class="layui-input date-icon"
                           readonly="readonly" lay-verType="tips" lay-verify="required" required/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">学号</label>
                <div class="layui-input-block">
                    <input name="username" placeholder="请输入学号" type="text" class="layui-input" maxlength="20"
                           lay-verType="tips" lay-verify="required" required/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">姓名</label>
                <div class="layui-input-block">
                    <input name="nickName" placeholder="请输入姓名" type="text" class="layui-input" maxlength="20"
                           lay-verType="tips" lay-verify="required" required/>
                </div>
            </div>
        </div>
        <div class="layui-col-md6">
            <div class="layui-form-item">
                <label class="layui-form-label" style="padding-left: 0;padding-right: 0;width: 98px;">个性标签</label>
                <div class="layui-input-block">
                    <input name="label" value="学霸,萌妹" class="layui-hide" lay-verType="tips"
                           lay-verify="required" required/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">手机号</label>
                <div class="layui-input-block">
                    <input name="phone" placeholder="请输入手机号" type="text" class="layui-input"
                           lay-verType="tips" lay-verify="required|phone" required/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">性别</label>
                <div class="layui-input-block">
                    <input type="radio" name="sex" value="男" title="男" checked/>
                    <input type="radio" name="sex" value="女" title="女"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">紧急联系人</label>
                <div class="layui-input-block">
                    <input name="jjContactUser" placeholder="请输入紧急联系人" type="text" class="layui-input"
                           lay-verType="tips" lay-verify="required" required/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" style="padding-left: 0;padding-right: 0;width: 98px;">紧急联系方式</label>
                <div class="layui-input-block">
                    <input name="jjContact" placeholder="请输入紧急联系方式" type="text" class="layui-input"
                           lay-verType="tips" lay-verify="required|phone" required/>
                </div>
            </div>
        </div>
        <div class="layui-form-item text-right">
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closePageDialog">取消</button>
            <button class="layui-btn" lay-filter="EDStudentModelSubmit" lay-submit>保存</button>
        </div>
    </form>
</script>


<script type="text/html" id="demoTableED1Bar">
    <a class="layui-btn layui-btn-primary layui-btn-sm" lay-event="view"><i class="layui-icon">&#xe6b2;</i>查看</a>
    <a class="layui-btn layui-btn-sm" lay-event="comments"><i class="layui-icon">&#xe63a;</i>评论</a>
</script>

<!-- 查看评论表格操作列 -->
<script type="text/html" id="demoTableEDCommentsBar">
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>

<!-- 查看评论弹窗 -->
<script type="text/html" id="demoEDCommentsModel">
    <table id="demoTableEDComments" lay-filter="demoTableEDComments" class="layui-hide"></table>
    <div class="btn-circle" id="demoEDBtnAddComment" style="position: absolute; bottom: 60px;" title="发表评论">
        <i class="layui-icon layui-icon-edit"></i>
    </div>
</script>

<!-- 查看详情弹窗 -->
{{--<script type="text/html" id="demoEDInfoModel">--}}
    {{--<div class="paper-info-group">--}}
        {{--<h3>本周工作总结</h3>--}}
        {{--<p></p>--}}
        {{--<h3>下周工作计划</h3>--}}
        {{--<p></p>--}}
        {{--<h3>备注</h3>--}}
        {{--<p></p>--}}
        {{--<div class="paper-info-group-imgs" id="paper-imgs">--}}
            {{--<img src="" width="130px" height="130px">--}}
        {{--</div>--}}
    {{--</div>--}}
{{--</script>--}}

<!-- 表格状态列 -->
{{--<script type="text/html" id="demoEDStateBar1">--}}

    {{--<span style="color: orange;cursor: default;" lay-tips="正在审核中，请耐心等待">待审核</span>--}}

{{--</script>--}}

<!-- 审核记录 -->
{{--<script id="demoEDCheckList" type="text/html">--}}
    {{--<div style="padding: 25px 0 0 30px;">--}}
        {{--<ul class="layui-timeline">--}}
            {{--<li class="layui-timeline-item">--}}
                {{--<i class="layui-icon layui-timeline-axis">&#xe63f;</i>--}}
                {{--<div class="layui-timeline-content layui-text">--}}
                    {{--<div class="layui-timeline-title">--}}
                        {{--<h3 class="inline-block">曲丽丽</h3>&emsp;2019-06-03 13:29--}}
                    {{--</div>--}}
                    {{--<p>提交了外出申请</p>--}}
                {{--</div>--}}
            {{--</li>--}}
            {{--<li class="layui-timeline-item">--}}
                {{--<i class="layui-icon layui-timeline-axis">&#xe63f;</i>--}}
                {{--<div class="layui-timeline-content layui-text">--}}
                    {{--<div class="layui-timeline-title">--}}
                        {{--<h3 class="inline-block">--}}
                            {{--林东东&nbsp;<span class="layui-badge layui-bg-green">组长</span>--}}
                        {{--</h3>&emsp;2019-06-03 13:48--}}
                    {{--</div>--}}
                    {{--<p>同意了申请（速去速回！）</p>--}}
                {{--</div>--}}
            {{--</li>--}}
            {{--<li class="layui-timeline-item">--}}
                {{--<i class="layui-icon layui-timeline-axis">&#xe63f;</i>--}}
                {{--<div class="layui-timeline-content layui-text">--}}
                    {{--<div class="layui-timeline-title">--}}
                        {{--<h3 class="inline-block">--}}
                            {{--周星星&nbsp;<span class="layui-badge layui-bg-blue">经理</span>--}}
                        {{--</h3>&emsp;2019-06-03 13:48--}}
                    {{--</div>--}}
                    {{--<p>同意了申请</p>--}}
                {{--</div>--}}
            {{--</li>--}}
            {{--<li class="layui-timeline-item">--}}
                {{--<i class="layui-icon layui-timeline-axis">&#xe63f;</i>--}}
                {{--<div class="layui-timeline-content layui-text">--}}
                    {{--<div class="layui-timeline-title">--}}
                        {{--<h3 class="inline-block">--}}
                            {{--付小小&nbsp;<span class="layui-badge layui-bg-orange">人事</span>--}}
                        {{--</h3>&emsp;2019-06-03 13:48--}}
                    {{--</div>--}}
                    {{--<p>同意了申请</p>--}}
                {{--</div>--}}
            {{--</li>--}}
        {{--</ul>--}}
    {{--</div>--}}
{{--</script>--}}

<!-- js部分 -->

<script>
    layui.use(['layer', 'admin', 'form', 'table', 'laytpl', 'util', 'laydate', 'cascader', 'tagsInput'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var admin = layui.admin;
        var form = layui.form;
        var table = layui.table;
        var laytpl = layui.laytpl;
        var util = layui.util;
        var laydate = layui.laydate;
        var cascader = layui.cascader;





        // 渲染表格
        var insTb = table.render({
            elem: '#demoTableED1',
            url: '../../json/e_d_t1.json',
            page: true,
            cellMinWidth: 100,
            cols: [[
                {type: 'numbers', title: '#'},
                {field: 'department', sort: true, title: '部门'},
                {field: 'position', sort: true, title: '职位'},
                {field: 'name', sort: true, title: '姓名'},
                {field: 'summary', sort: true, title: '本周工作总结'},
                {field: 'plan', sort: true, title: '下周工作计划'},
                {field: 'comments', sort: true, title: '备注'},
                {
                    sort: true, title: '发布时间', templet: function (d) {
                        return util.toDateString(d.createTime);
                    }
                },
                {toolbar: '#demoEDStateBar1', sort: true, title: '状态'},
                {align: 'center', toolbar: '#demoTableED1Bar', title: '操作', minWidth: 180}
            ]],
            size: 'lg'
        });

        // 工具条点击事件
        table.on('tool(demoTableED1)', function (obj) {
            var data = obj.data;
            var layEvent = obj.event;
            if (layEvent === 'comments') {  // 查看评论
                showComments(data.id);
            } else if (layEvent == 'view') {
                showInfo(data);
            } else if (layEvent == 'checkList') {
                openCheckList(data);
            }
        });

        // 查看详情
        function showInfo(data) {
            laytpl(demoEDInfoModel.innerHTML).render(data, function (html) {
                admin.open({
                    type: 1,
                    title: '查看详情',
                    area: '550px',
                    content: html,
                    success: function () {
                        layer.photos({
                            photos: '#paper-imgs',
                            shade: .1,
                            closeBtn: true
                        });
                    }
                });
            });
        }

        // 查看评论
        function showComments(id) {
            admin.open({
                type: 1,
                area: '650px',
                offset: '65px',
                title: '查看评论',
                content: $('#demoEDCommentsModel').html(),
                success: function () {
                    // 渲染表格
                    var insTbCom = table.render({
                        elem: '#demoTableEDComments',
                        url: '../../json/e_d_c1.json?id=' + id,
                        page: true,
                        height: 400,
                        cellMinWidth: 100,
                        cols: [[
                            {type: 'numbers', title: '#'},
                            {field: 'nickName', sort: true, title: '评论人', width: 100},
                            {field: 'content', sort: true, title: '评论内容'},
                            {
                                title: '评论时间', sort: true, templet: function (d) {
                                    return util.toDateString(d.createTime);
                                }
                            },
                            {align: 'center', toolbar: '#demoTableEDCommentsBar', title: '操作', minWidth: 80, width: 80}
                        ]]
                    });

                    // 查看评论工具条点击事件
                    table.on('tool(demoTableEDComments)', function (obj) {
                        var data = obj.data;
                        var layEvent = obj.event;
                        if (layEvent === 'del') { // 删除
                            layer.msg('删除成功', {icon: 1});
                        }
                    });

                    // 发表评论
                    $('#demoEDBtnAddComment').click(function () {
                        layer.prompt({
                            title: '发表评论',
                            shade: .1,
                            offset: '165px',
                            skin: 'layui-layer-admin layui-layer-prompt',
                            formType: 2
                        }, function (value, index, elem) {
                            layer.close(index);
                            layer.msg('评论成功', {icon: 1});
                        });
                    });

                }
            });
        }

        // 审核记录弹窗
        function openCheckList(d) {
            laytpl(demoEDCheckList.innerHTML).render(d, function (html) {
                admin.open({
                    type: 1,
                    title: '审核详情',
                    content: html
                });
            });
        }



        // 添加商品
        $('#demoEDBtnAddStudent').click(function () {
            admin.open({
                type: 1,
                title: '添加商品',
                area: '90%',
                content: $('#EDModelAddStudent').html(),
                success: function (layero, dIndex) {


                    var resTmp=[];
                    $.get('/admin/goods/speci/lists', '', function (res) {
                        var result = JSON.parse(res);
                        console.log(result)
                        for (var i=0; i<result.data.length;i++) {
                            resTmp.push(result.data[i]['name'])
                        }
                        console.log(resTmp.join(','))
                        $("#specia").val(resTmp.join(','))
                    })

                    // 模拟后台数据
                    let moke =	[{
                        color: "土豪金", size: "64G", version: "港版", price: "6767", store: "57",
                        propvalnames:{propvalids: "31,13,22", skuStock: "57", skuPrice: "6767"}},
                        {
                            color: "土豪金", size: "128G", version: "港版", price: "5675", store: "67",
                            propvalnames:{
                                propvalids: "31,14,22", skuStock: "67", skuPrice: "5675"}
                        }
                    ]

                    for(let item of moke){
                        console.log(item, '657657')
                        let propvalids = item['propvalnames']['propvalids'].split(',')

                        $(".sku_value").each(function (i, item) {
                            let propvalid =$(this).attr('propvalid')
                            if(propvalids.includes(propvalid) ){
                                $(this).attr('checked', true)
                            }
                        })


                        alreadySetSkuVals[item['propvalnames']['propvalids']] = {
                            "skuPrice" : item['propvalnames']['skuPrice'],
                            "skuStock" : item['propvalnames']['skuStock']
                        }
                    }
                    createTab()
                    $('.btn').on('click', () => {

                        let tabTitles = ['color', 'size', 'version','price','store'];
                        let arrJson = []
                        let alreadySetSkuVals = [];
                        //获取设置的SKU属性值
                        $("tr[class*='sku_table_tr']").each(function (i, item) {
                            let newObj = {}
                            var skuPrice = $(this).find("input[type='text'][class*='setting_sku_price']").val() || 0;//SKU价格
                            var skuStock = $(this).find("input[type='text'][class*='setting_sku_stock']").val() || 0;//SKU库存
                            // if(skuPrice || skuStock){//已经设置了全部或部分值
                            let propvalids = $(this).attr('propvalids')// 31,13,22
                            let propvalnames = $(this).attr('propvalnames') // 土豪金;64G;港版


                            let names = propvalnames.split(';')
                            for (let j = 0; j < names.length; j++) {
                                newObj[tabTitles[j]] = names[j]
                            }
                            newObj[tabTitles[names.length]] = skuPrice
                            newObj[tabTitles[names.length + 1]] = skuStock
                            newObj['propvalnames'] = {propvalids,skuStock, skuPrice}
                            alreadySetSkuVals.push(newObj)
                        });
                        console.log(alreadySetSkuVals, '获取已经设置的SKU值')
                        getAlreadySetSkuVals();//获取已经设置的SKU值
                    })








                    $(layero).children('.layui-layer-content').css('overflow', 'visible');
                    form.render('radio');
                    // 表单提交事件
                    form.on('submit(EDStudentModelSubmit)', function (data) {
                        layer.msg("表单验证通过", {icon: 1});
                        return false;
                    });
                    // 专业选择
                    cascader.render({
                        elem: '#EDStudentForm input[name="profession"]',
                        itemHeight: '220px',
                        data: [{
                            label: '计算机学院',
                            value: '1',
                            children: [{
                                label: '软件技术',
                                value: '1-1'
                            }, {
                                label: '计算机网络技术',
                                value: '1-2'
                            }, {
                                label: '计算机信息管理',
                                value: '1-3'
                            }, {
                                label: '物联网应用技术',
                                value: '1-4'
                            }, {
                                label: '数字媒体应用技术',
                                value: '1-5'
                            }, {
                                label: '移动互联应用技术',
                                value: '1-6'
                            }]
                        }, {
                            label: '机械工程学院',
                            value: '2',
                            children: [{
                                label: '模具设计与制造',
                                value: '2-1'
                            }, {
                                label: '机械设计与制造',
                                value: '2-2'
                            }, {
                                label: '数控技术',
                                value: '2-3'
                            }, {
                                label: '机械制造与自动化',
                                value: '2-4'
                            }]
                        }, {
                            label: '商学院',
                            value: '3',
                            children: [{
                                label: '电子商务',
                                value: '3-1'
                            }, {
                                label: '物流管理',
                                value: '3-2'
                            }, {
                                label: '报关与国际货运',
                                value: '3-3'
                            }, {
                                label: '连锁经营管理',
                                value: '3-4'
                            }, {
                                label: '旅游管理',
                                value: '3-5'
                            }, {
                                label: '商务英语',
                                value: '3-6'
                            }, {
                                label: '会计',
                                value: '3-7'
                            }, {
                                label: '金融管理',
                                value: '3-8'
                            }, {
                                label: '工商企业管理',
                                value: '3-9'
                            }]
                        }]
                    });
                    // 年选择器
                    laydate.render({
                        elem: '#EDStudentForm input[name="schoolYear"]',
                        type: 'year',
                        trigger: 'click'
                    });
                    // 标签输入框
                    $('#EDStudentForm input[name="label"]').tagsInput({
                        skin: 'tagsinput-default',
                        autocomplete_url: '../../json/tagsInput.json'
                    });
                }
            });

        });

    });
</script>

<link rel="stylesheet" href="{{ asset('/admin/libs/sku/sku_style.css') }}"/>
<link rel="stylesheet" href="{{ asset('/admin/libs/selectpage/selectpage.css') }}"/>
<script>
    // 模拟后台数据
    let moke =	[{
        color: "土豪金", size: "64G", version: "港版", price: "6767", store: "57",
        propvalnames:{propvalids: "31,13,22", skuStock: "57", skuPrice: "6767"}},
        {
            color: "土豪金", size: "128G", version: "港版", price: "5675", store: "67",
            propvalnames:{
                propvalids: "31,14,22", skuStock: "67", skuPrice: "5675"}
        }
    ]

    for(let item of moke){
        console.log(item, '657657')
        let propvalids = item['propvalnames']['propvalids'].split(',')

        $(".sku_value").each(function (i, item) {
            let propvalid =$(this).attr('propvalid')
            if(propvalids.includes(propvalid) ){
                $(this).attr('checked', true)
            }
        })


        alreadySetSkuVals[item['propvalnames']['propvalids']] = {
            "skuPrice" : item['propvalnames']['skuPrice'],
            "skuStock" : item['propvalnames']['skuStock']
        }
    }
    createTab()
    $('.btn').on('click', () => {

        let tabTitles = ['color', 'size', 'version','price','store'];
        let arrJson = []
        let alreadySetSkuVals = [];
        //获取设置的SKU属性值
        $("tr[class*='sku_table_tr']").each(function (i, item) {
            let newObj = {}
            var skuPrice = $(this).find("input[type='text'][class*='setting_sku_price']").val() || 0;//SKU价格
            var skuStock = $(this).find("input[type='text'][class*='setting_sku_stock']").val() || 0;//SKU库存
            // if(skuPrice || skuStock){//已经设置了全部或部分值
            let propvalids = $(this).attr('propvalids')// 31,13,22
            let propvalnames = $(this).attr('propvalnames') // 土豪金;64G;港版


            let names = propvalnames.split(';')
            for (let j = 0; j < names.length; j++) {
                newObj[tabTitles[j]] = names[j]
            }
            newObj[tabTitles[names.length]] = skuPrice
            newObj[tabTitles[names.length + 1]] = skuStock
            newObj['propvalnames'] = {propvalids,skuStock, skuPrice}
            alreadySetSkuVals.push(newObj)
        });
        console.log(alreadySetSkuVals, '获取已经设置的SKU值')
        getAlreadySetSkuVals();//获取已经设置的SKU值
    })
</script>


<script>



</script>
</body>
</html>